<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('国家地区管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>地区名称：</p>
                                <input type="text" name="areasName"/>
                            </li>
                            <li>
                                <p>地区代码：</p>
                                <input type="text" name="areasCode"/>
                            </li>
                            <li>
                                <p>地区类型：</p>
                                <select name="areasType" th:with="type=${@dict.getType('')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>父地区标识：</p>
                                <input type="text" name="parentId"/>
                            </li>
                            <li>
                                <p>状态：</p>
                                <input type="text" name="memberState"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="vtsp:areas:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="vtsp:areas:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="vtsp:areas:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="vtsp:areas:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table">
                    <thead>
                        <tr>
                            <th data-checkbox="true"></th>
                            <th data-formatter="fm_rowIndex" data-align="center">序号</th>
                            <th data-field="areasName">地区名称</th>
                            <th data-field="areasCode">地区代码</th>
                            <th data-field="areasType">地区类型</th>
                            <th data-field="parentId">父地区标识</th>
                            <th data-field="memberState" data-formatter="fm_memberState">状态</th>
                            <th data-field="memo">备注</th>
                            <th data-formatter="fm_commands" data-width="120px" data-align="center">操作</th> 
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('vtsp:areas:edit')}]];
        var removeFlag = [[${@permission.hasPermi('vtsp:areas:remove')}]];
        var memberStateDatas = [[${@dict.getType('sys_state_id')}]];
        var prefix = ctx + "vtsp/areas";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "国家地区管理",
                uniqueId: "areasId"            
            };
            $.table.init(options);
        });
        
        //状态
        function fm_memberState(value, row, index) {
            return $.table.selectDictLabel(memberStateDatas, value);
        }
        
        //命令  
        function fm_commands(value, row, index){
            var actions = [];
            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.areasId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.areasId + '\')"><i class="fa fa-remove"></i>删除</a>');
            return actions.join('');
        }
    </script>
</body>
</html>